/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package phd.dupenois.datatrees;

import java.util.Vector;

/**
 *
 * @param <T>
 * @author mpd209
 */
public class Node<T>{
    private Node<T> left;
    private Node<T> right;
    private Node<T> parent;
    private T value;
    private int distanceFromTop;
    public Node(){}

    /**
     * @return the left
     */
    public Node<T> getLeft() {
        return left;
    }

    /**
     * @param left the left to set
     */
    public void setLeft(Node<T> left) {
        this.left = left;
    }

    /**
     * @return the right
     */
    public Node<T> getRight() {
        return right;
    }

    /**
     * @param right the right to set
     */
    public void setRight(Node<T> right) {
        this.right = right;
    }

    /**
     * @return the parent
     */
    public Node<T> getParent() {
        return parent;
    }



//    public int getHeight(){
//
//    }
//
//
//    public int getWidth(){
//
//    }



    public Vector<Node> getAllChildren(){
        Vector<Node> children = new Vector<Node>();
        if(this.isLeaf()) return children;
        if(this.left!=null){
            children.add(this.left);
            children.addAll(this.left.getAllChildren());
        }
        if(this.right!=null){
            children.add(this.right);
            children.addAll(this.right.getAllChildren());
        }
        return children;
    }

    /**
     * @param parent the parent to set
     */
    public void setParent(Node<T> parent) {
        this.parent = parent;
    }

    public boolean isTreeRoot(){
        return (this.parent==null);
    }
    public boolean isLeaf(){
        return (this.left==null&&this.right==null);
    }
    public boolean hasLeft(){
        return (this.left!=null);
    }
    public boolean hasRight(){
        return (this.right!=null);
    }
    /**
     * @return the value
     */
    public T getValue() {
        return value;
    }

    /**
     * @param value the value to set
     */
    public void setValue(T value) {
        this.value = value;
    }

    /**
     * @return the distanceFromTop
     */
    public int getDistanceFromTop() {
        return distanceFromTop;
    }

    /**
     * @param distanceFromTop the distanceFromTop to set
     */
    public void setDistanceFromTop(int distanceFromTop) {
        this.distanceFromTop = distanceFromTop;
    }

    



}
